package com.fy56.platform.logistics.service.impl;

import com.fy56.platform.logistics.common.ResultModel;
import com.fy56.platform.logistics.common.ResultStatus;
import com.fy56.platform.logistics.mapper.WeChatProgramMapper;
import com.fy56.platform.logistics.model.WeChatProgram;
import com.fy56.platform.logistics.service.web.IWeChatProgramService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Ning on 2018/5/7 .
 */
@Service
public class WeChatProgramServiceImpl implements IWeChatProgramService {

    @Autowired
    private WeChatProgramMapper weChatProgramMapper;

    @Override
    public WeChatProgram getWeChatProgram() {
        return weChatProgramMapper.getWeChatProgram();
    }

    @Override
    @Transactional(readOnly = false)
    public ResultModel save(WeChatProgram entity) {
        int r = 0;
        ResultModel result = new ResultModel(ResultStatus.EDIT_ERR);;
        if(null != entity.getId()){
            r = weChatProgramMapper.updateByPrimaryKeySelective(entity);
        }
        if(r == 0){
            weChatProgramMapper.deleteAll();
            r = weChatProgramMapper.insert(entity);
        }
        if (r != 0) {
            result = ResultModel.ok();
        }
        return result;
    }

    @Override
    public WeChatProgram get(WeChatProgram entity) {
        return weChatProgramMapper.get(entity);
    }

    @Override
    public ResultModel insert(WeChatProgram entity) {
        return null;
    }

    @Override
    public ResultModel updateSelective(WeChatProgram entity) {
        return null;
    }

    @Override
    public WeChatProgram selectByPrimaryKey(Long id) {
        return null;
    }

    @Override
    public List<WeChatProgram> findList(WeChatProgram entity) {
        return null;
    }

    @Override
    public ResultModel delete(Long id) {
        return null;
    }

    @Override
    public ResultModel insertSelective(WeChatProgram entity) {
        return null;
    }

    @Override
    public ResultModel update(WeChatProgram entity) {
        return null;
    }

    @Override
    public ResultModel delete(WeChatProgram entity) {
        return null;
    }
}
